<div id="top-panel">
    <div id="panel">
        <ul>
            <li><a href="<?php echo site_url("trivia"); ?>" class="report_seo">List</a></li>			
        </ul>
    </div>
</div>
<script language="javascript">
	var jq = jQuery.noConflict();
	jq(document).ready(function(){
		jq("#trivia")	.change(function(){
			if(jq(this).val()==0){
				jq("#question option").remove();	
				return false;
			}
			else{
				var val		= {'tid' : jq(this).val()};
				var a 		= jq(".hidden-question").attr('href');
				jq.post(a, val, function(data){				
					parse_question_data(data);
				});
			}			
		});
		
		
		function parse_question_data(data){
			jq("#question option").remove();			
			var obj = jQuery.parseJSON(data);
			for(var i=0; i<obj.length; i++){
				var str = '<option value="'+obj[i].id+'">'+obj[i].question+'</option>';
				jq("#question").append(str);
			}		
		}
	});
</script>
<div id="wrapper">
	<div id="content">
		<div id="rightnow">
			<h3 class="reallynow">Assign trivia game</h3>
			<div>
				<?php echo validation_errors(); ?>
			</div>
			<?php echo form_open('trivia/save_assign') ?>			
			<table width="100%">
				<tr>
					<td>Trivia game</td>
					<td>
						<?php if(count($trivia)>0): ?>
						<select name="id" id="trivia" class="input2">
							<option value="0">Select game</option>	
							<?php foreach($trivia as $v): ?>
							<option value="<?php echo $v['id']; ?>"><?php echo $v['title'] ?></option>		
							<?php endforeach; ?>
							<?php endif; ?>					
						</select>	
					</td>
				</tr>
				<tr>
					<td>Question</td>
					<td><select name="q_id[]" id="question" multiple="multiple" class="input2" size="10"></select><div id="chk"></div></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input type="submit" value="Save" >
						<input type="button" value="Cancel" class="btcancel" /></td>
				<tr>
			</table>
		</div>
	</div>
	<a class="hidden-question" href="<?php echo site_url('trivia/get_question'); ?>"></a>
</div>